package com.dykj.fireFighting.server.elasticsearch.controller;


import com.dykj.fireFighting.api.elasticsearch.device.entity.EsDevice;
import com.dykj.fireFighting.api.elasticsearch.device.service.EsDeviceService;
import com.dykj.fireFighting.server.elasticsearch.commons.CommonResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.data.domain.Page;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;


/**
 * 设备管理-智能设备接口
 *
 * @Author JacksonTu
 * @Date 2021-06-22 15:55:39
 */
@Slf4j
@Api(value = "搜索设备管理-智能设备接口", tags = {"搜索设备管理-智能设备接口"})
@Controller
@RequestMapping("/elasticsearch")
public class EsDeviceController {


    @DubboReference
    private EsDeviceService esDeviceService;


    /**
     * @return
     */
    @ApiOperation(value = "查询所有es")
    @RequestMapping(value = "/selectAll", method = RequestMethod.POST)
    @ResponseBody
    public CommonResult<Page<EsDevice>> selectAll(@RequestParam(required = false) String keyword,
                                                  @RequestParam(required = false, defaultValue = "0") Integer pageNum,
                                                  @RequestParam(required = false, defaultValue = "5") Integer pageSize) {
        Page<EsDevice> page = esDeviceService.search(keyword, pageNum, pageSize);
        return CommonResult.success(page);
    }
}
